let obj1 = {
  a: 1,
  b: 2
}

let obj2 = {
  a: 1,
  b: 3
}

function equal(obj1, obj2) {
  if (obj1 === obj2) {
    return true
  }
  if ((obj1 === null || typeof obj1 !== 'object') || (obj2 === null || typeof obj2 !== 'object')) {
    return false;
  }

  if (Object.keys(obj1).length !== Object.keys(obj2).length) {
    return false
  }

  for (let key of Object.keys(obj1)) {
    if (!obj2.hasOwnProperty(key) || !equal(obj1[key], obj2[key])) {
      return false
    }
  }
  return true
}

console.log(equal(obj1, obj2));



// console.log(JSON.stringify(obj1) == JSON.stringify(obj2));
